import { PageHeader } from 'antd';
import { Button, Checkbox, Form, Input, Select, Progress } from 'antd';
import './index.scss'
import { useEffect, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { getall } from '../../../../../api/frremember_ssh'
const { Option } = Select;
const routes = [
    {
        path: 'index',
        breadcrumbName: '用户管理',
    },
    {
        path: 'first',
        breadcrumbName: '免费会员等级管理',
    },
    {
        path: 'second',
        breadcrumbName: '配置会员等级',
    },
];
const New_members = () => {
    useEffect(() => {
        getfreemember()
    }, [])
    const [value2, setValue2] = useState([])
    const getfreemember = () => {
        getall().then((res) => {
            console.log(res);
            let qunyi = res.data[0]
            setValue2(qunyi.vipLevelEquityList)

        })
    }
    const selectListRender = (arr) => {

        let list = []
        arr.map((v, i) => list.push(<Select.Option value={v.equityName}>{v.equityName}</Select.Option>))
        return list
    }
    const Navigate = useNavigate()
    const onFinish = (values) => {
        console.log('Success:', values);
    };
    const onFinishFailed = (errorInfo) => {
        console.log('Failed:', errorInfo);
    };
    const goback = () => {
        Navigate('/home/user/free-member')
    }
    return <div className='newmember'>
        <PageHeader
            className="site-page-header"
            title="配置会员等级"
            breadcrumb={{
                routes,
            }}

        />
        <div className='content_editor clear'>
            <div className='left'>
                <Form
                    name="basic"
                    labelCol={{
                        span: 6,
                    }}
                    wrapperCol={{
                        span: 16,
                    }}

                    onFinish={onFinish}
                    onFinishFailed={onFinishFailed}
                    autoComplete="off"
                >
                    <Form.Item
                        label="等级名称"
                        name="vipName"
                    >
                        <Input />
                    </Form.Item>
                    <Form.Item
                        name="remember"
                        valuePropName="checked"
                        wrapperCol={{
                            offset: 1,
                            span: 23,
                        }}
                        label="升级条件"
                    >
                        注册会员
                        <span>仅Lv1级可编辑此信息</span>

                    </Form.Item>
                    <Form.Item
                        name="sumPay"
                        valuePropName="checked"
                        wrapperCol={{
                            offset: 7,
                            span: 17,
                        }}

                    >
                        累计消费
                        <Input suffix="元" placeholder='请输入' className='myinput' />



                    </Form.Item>
                    <Form.Item
                        name="growValue"
                        valuePropName="checked"
                        wrapperCol={{
                            offset: 7,
                            span: 17,
                        }}

                    >
                        成长值 &nbsp;
                        <Input placeholder='请输入' className='myinput' />



                    </Form.Item>
                    <Form.Item
                        name="vipLevelEquityList"
                        valuePropName="checked"
                        wrapperCol={{
                            offset: 1,
                            span: 23,
                        }}
                        label="会员权益"
                    >
                        <Select
                        >
                            {selectListRender(value2)}
                        </Select>
                    </Form.Item>
                    <Form.Item
                        name="upgradeGift"
                        valuePropName="checked"
                        wrapperCol={{
                            offset: 1,
                            span: 23,
                        }}
                        label="升级礼包"
                    >
                        {/* <Checkbox>送优惠券</Checkbox> */}

                    </Form.Item>
                    <Form.Item
                        name="integral"
                        valuePropName="checked"
                        wrapperCol={{
                            offset: 7,
                            span: 17,
                        }}

                    >
                        送积分
                        <Input suffix="分" placeholder='请输入' className='myinput' />
                    </Form.Item>
                    <Form.Item
                        wrapperCol={{
                            offset: 8,
                            span: 16,
                        }}
                    >
                        <Button type="primary" htmlType="submit">
                            提交
                        </Button>
                        &nbsp; &nbsp; &nbsp;
                        <Button htmlType="submit" onClick={goback}>
                            返回
                        </Button>
                    </Form.Item>
                </Form>
            </div>
            <div className='right'>
                <div className='car'>
                    <h3 className='myh'>会员名称</h3>
                    <div className='bottm'>
                        <h3><span className='myi'>560</span>/1000</h3>
                        <Progress percent={56} strokeColor='white' trailColor='rgba(255, 255, 255,0.5)' showInfo={false} />
                        <p>成长值 距离升级还有600成长值</p>
                    </div>
                </div>
                <p className='mypp'>会员卡预览</p>
            </div>

        </div>
    </div>
}
export default New_members